import * as VueRouter from "vue-router";
//路由规则描述数组

const routes = [
  { path: "/", redirect: "/WindowMain/Home" },
  {
    path: "/WindowMain",
    component: () => import("./window/WindowMain.vue"),
    children: [
      { path: "Home", component: () => import("./window/WindowMain/Home.vue") },
      { path: "Memo", component: () => import("./window/WindowMain/Memo/Memo.vue") },
      { path: "Diary", component: () => import("./window/WindowMain/Diary.vue") },
      { path: "Collect", component: () => import("./window/WindowMain/Collect.vue") },
      {
        path: "Explain",
        component: () => import("./window/WindowMain/Explain.vue"),
      },
      {
        path: "QwenPlus",
        component: () => import("./window/WindowMain/QwenPlus/index.vue"),
        beforeEnter: (to: any, from: any, next: any) => {
          // 将来源路由信息存储在查询参数中
          if (from.path === '/WindowMain/Setting/Conversation') {
            to.query.fromConversation = 'true';
          }
          next();
        }
      },
      {
        path: "Setting/Resource",
        component: () => import("./window/WindowMain/Setting/Resource.vue"),
      },
      {
        path: "Setting/Property",
        component: () => import("./window/WindowMain/Setting/Property.vue"),
      },
      {
        path: "Setting/Conversation",
        component: () => import("./window/WindowMain/Setting/Conversation.vue"),
      },
    ],
  },
];

//导出路由对象
export let router = VueRouter.createRouter({
  history: VueRouter.createWebHistory(),
  routes,
});